package com.student.controller;

import com.student.dto.ResponseDto;
import com.student.pojo.SnackGoodsCate;
import com.student.service.SnackGoodsCateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @BelongsProject: makeups
 * @BelongsPackage: com.student.controller
 * @Author: 小徐
 * @CreateTime: 2024-12-21 17:30
 * @Description: TODO
 * @Version: 1.0
 */
@RestController
@RequestMapping("type")
public class SnackGoodsCateController {
    @Autowired
    private SnackGoodsCateService snackGoodsCateService;


    //     这边是渲染所有的分类信息
    @RequestMapping("getAllSnackType")
    public ResponseDto getAllSnackType(@RequestBody SnackGoodsCate snackGoodsCate) {

        return snackGoodsCateService.getAllSnackType(snackGoodsCate);
    }

    //     这边是渲染所有的分类信息
    @RequestMapping("getAllType")
    public ResponseDto getAllType() {

        return snackGoodsCateService.getAllType();
    }

    /**
     * 添加类别
     *
     * @param snackGoodsCate
     * @return
     */
    @RequestMapping("addSnackType")
    public ResponseDto addSnackType(@RequestBody SnackGoodsCate snackGoodsCate) {
        System.err.println(snackGoodsCate);
        return snackGoodsCateService.addSnackType(snackGoodsCate);
    }

    /**
     * 删除类别
     */
    @RequestMapping("deleteSnackType")
    public ResponseDto deleteSnackType(@RequestParam("id") Integer id) {
        return snackGoodsCateService.deleteSnackType(id);
    }

    //修改类别
    @RequestMapping("updateSnackType")
    public ResponseDto updateSnackType(@RequestBody SnackGoodsCate snackGoodsCate) {
        return snackGoodsCateService.updateSnackType(snackGoodsCate);
    }

    @RequestMapping("getAllzimu")
    public ResponseDto getAllzimu() {
        return snackGoodsCateService.getAllzimu();
    }
}